package controlStructure;

import java.util.Scanner;

/**
 * 多重循环控制（最多不要超过三层）
 */
public class MulFor {

    public static void main(String[] args) {

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.println("i=" + i + " j=" + j);
            }
        }

        //统计3个班成绩，每个班5名同学，求各个班的平均分和所有班级平均分（成绩键盘输入）
        //统计3个班及格人数，每个班有5名同学
        double sum = 0.0;
        Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= 3; i++) {
            int num = 0;
            double perSum = 0.0;
            System.out.println("请输入学生成绩");
            for (int j = 1; j <= 5; j++) {
                double score = scanner.nextDouble();
                if (score >= 60.0) {
                    num++;
                }
                perSum += score;
            }
            double average = perSum / 5.0;
            sum += perSum;
            System.out.println("第" + i + "个班平均分为：" + average + "，及格人数：" + num);
        }
        System.out.println("所有班平均分为：" + sum / 3.0);
    }
}
